<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopGoodsSpec extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('shop_goods_spec',['engine'=>'InnoDB'])->setComment('商品规格');
        $table->addColumn(Column::bigInteger('gid')->setDefault(0)->setComment('商品id'));
        $table->addColumn(Column::string('spec_title')->setNullable()->setComment('规格标题'));
        $table->addColumn(Column::string('goods_title')->setNullable()->setComment('商品标题'));
        $table->addColumn(Column::string('spec_name')->setNullable()->setComment('规格名称'));
        $table->addColumn(Column::string('spec_type')->setNullable()->setComment('规格类型'));
        $table->addColumn(Column::text('spec')->setNullable()->setComment('规格名'));
        $table->addColumn(Column::string('degrees')->setNullable()->setComment('规格值'));
        $table->addColumn(Column::string('spec_group')->setNullable()->setComment('搜索组合'));
        $table->addColumn(Column::decimal('price_market',12,2)->setDefault(0)->setComment('规格原价'));
        $table->addColumn(Column::decimal('price',12,2)->setDefault(0)->setComment('商品价格'));
        $table->addColumn(Column::decimal('seckill_price',12,2)->setDefault(0)->setComment('秒杀价格'));
        $table->addColumn(Column::decimal('spell_price',12,2)->setDefault(0)->setComment('拼团价格'));
        $table->addColumn(Column::bigInteger('stock')->setDefault(0)->setComment('商品库存统计'));
        $table->addColumn(Column::bigInteger('sale')->setDefault(0)->setComment('已销售数量'));
        $table->addColumn(Column::bigInteger('number_virtual')->setDefault(0)->setComment('虚拟销量'));
        $table->addColumn(Column::string('thumb',500)->setNullable()->setComment('规格图片'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态(0:禁用,1:启用)'));
        $table->addColumn(Column::tinyInteger('is_deleted')->setDefault(0)->setComment('删除(1:删除,0:未删)'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
